package com.ruoyi.safety.service.impl;

import java.util.HashMap;
import java.util.List;
import java.util.Map;

import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl; //添加
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.safety.mapper.SafetyPointRealHistoryMapper;
import com.ruoyi.safety.domain.SafetyPointRealHistory;
import com.ruoyi.safety.service.ISafetyPointRealHistoryService;

/**
 * 测点历史信息数据Service业务层处理
 *
 * @author ruoyi
 * @date 2024-11-12
 */
@Service
public class SafetyPointRealHistoryServiceImpl extends ServiceImpl<SafetyPointRealHistoryMapper, SafetyPointRealHistory> implements ISafetyPointRealHistoryService //修改
{
    @Autowired
    private SafetyPointRealHistoryMapper safetyPointRealHistoryMapper;

    /**
     * 查询测点历史信息数据
     *
     * @param id 测点历史信息数据主键
     * @return 测点历史信息数据
     */
    @Override
    public SafetyPointRealHistory selectSafetyPointRealHistoryById(String id) {
        return safetyPointRealHistoryMapper.selectSafetyPointRealHistoryById(id);
    }

    /**
     * 查询测点历史信息数据列表
     *
     * @param safetyPointRealHistory 测点历史信息数据
     * @return 测点历史信息数据
     */
    @Override
    public List<SafetyPointRealHistory> selectSafetyPointRealHistoryList(SafetyPointRealHistory safetyPointRealHistory) {
        return safetyPointRealHistoryMapper.selectSafetyPointRealHistoryList(safetyPointRealHistory);
    }

    /**
     * 查询测点历史信息近三天平均数据
     *
     * @return 测点历史信息数据集合
     */
    @Override
    public String selectSafetyPointRealHistoryListThreeAvg(String sensorTypeName,String pointInstallLocation) {
        return safetyPointRealHistoryMapper.selectSafetyPointRealHistoryListThreeAvg(sensorTypeName,pointInstallLocation);
    }

    /**
     * 查询测点历史信息近一天平均数据
     *
     * @return 测点历史信息数据集合
     */
    @Override
    public String selectSafetyPointRealHistoryListOneAvg(String sensorTypeName, String pointInstallLocation) {
        return safetyPointRealHistoryMapper.selectSafetyPointRealHistoryListOneAvg(sensorTypeName,pointInstallLocation);
    }

    /**
     * 查询测点历史信息自定义时间平均数据
     *
     * @return 测点历史信息数据集合
     */
    @Override
    public String selectSafetyPointRealHistoryListCustomTime(String sensorTypeName, String pointInstallLocation, String customTime) {
        return safetyPointRealHistoryMapper.selectSafetyPointRealHistoryListCustomTime(sensorTypeName,pointInstallLocation,customTime);
    }

    /**
     * 新增测点历史信息数据
     *
     * @param safetyPointRealHistory 测点历史信息数据
     * @return 结果
     */
    @Override
    public int insertSafetyPointRealHistory(SafetyPointRealHistory safetyPointRealHistory) {
        return safetyPointRealHistoryMapper.insertSafetyPointRealHistory(safetyPointRealHistory);
    }

    /**
     * 修改测点历史信息数据
     *
     * @param safetyPointRealHistory 测点历史信息数据
     * @return 结果
     */
    @Override
    public int updateSafetyPointRealHistory(SafetyPointRealHistory safetyPointRealHistory) {
        return safetyPointRealHistoryMapper.updateSafetyPointRealHistory(safetyPointRealHistory);
    }

    /**
     * 批量删除测点历史信息数据
     *
     * @param ids 需要删除的测点历史信息数据主键
     * @return 结果
     */
    @Override
    public int deleteSafetyPointRealHistoryByIds(String[] ids) {
        return safetyPointRealHistoryMapper.deleteSafetyPointRealHistoryByIds(ids);
    }

    /**
     * 删除测点历史信息数据信息
     *
     * @param id 测点历史信息数据主键
     * @return 结果
     */
    @Override
    public int deleteSafetyPointRealHistoryById(String id) {
        return safetyPointRealHistoryMapper.deleteSafetyPointRealHistoryById(id);
    }

    @Override
    public void insertDataBatch(List<SafetyPointRealHistory> safetyPointRealHistoryArrayList) {

        safetyPointRealHistoryMapper.insertDataBatch(safetyPointRealHistoryArrayList);

//        Map<String, Object> params = new HashMap<>();
//        String tableName = safetyPointRealHistoryMapper.getNewTableName();
//        // 动态指定的表名
//        params.put("tableName", tableName);
//        params.put("list", safetyPointRealHistoryArrayList); // 要插入的数据列表
//        safetyPointRealHistoryMapper.insertDataBatch(params);
        return;
    }


}
